#include <iostream>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <cstring>

#define FIFO_FILE "fifo_pipe"

int main() {
    // 打开管道以读取模式
    int fd = open(FIFO_FILE, O_RDONLY);
    if (fd == -1) {
        perror("open error");
        return 1;
    }

    // 从管道读取数据
    char buffer[100];
    ssize_t bytesRead = read(fd, buffer, sizeof(buffer));
    if (bytesRead > 0) {
        std::cout << "Received: " << buffer << std::endl;
    } else {
        perror("read error");
    }

    close(fd); // 关闭文件描述符
    return 0;
}
